#include "ostree-mount-util.h"
+static GOptionEntry options[] = { { NULL } };
+
static bool
sysroot_is_configured_ro (const char *sysroot)
{
struct stat stbuf;
g_autoptr (GError) error = NULL;
+ g_autoptr (GOptionContext) context = g_option_context_new ("SYSROOT [KERNEL_CMDLINE]");
+ g_option_context_add_main_entries (context, options, NULL);
+ if (!g_option_context_parse (context, &argc, &argv, &error))
+ errx (EXIT_FAILURE, "Error parsing options: %s", error->message);
+
if (argc < 2)
- err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT");
+ err (EXIT_FAILURE, "usage: ostree-prepare-root SYSROOT [KERNEL_CMDLINE]");
const char *root_arg = argv[1];
- g_autofree char *kernel_cmdline = read_proc_cmdline ();
+ g_autofree char *kernel_cmdline = NULL;
+ if (argc < 3)
+ {
+ kernel_cmdline = read_proc_cmdline ();
+ }
+ else
+ {
+ // Duplicate argv[2] so g_autofree can safely manage it.
+ kernel_cmdline = g_strdup (argv[2]);
+ }
+
if (!kernel_cmdline)
errx (EXIT_FAILURE, "Failed to read kernel cmdline");